package Controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.HelperHtml;
import model.TourDAO;

/**
 * Servlet implementation class Booked
 */
@WebServlet("/Booked")
public class Booked extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Booked() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setCharacterEncoding("utf-8");
		response.getWriter().write(HelperHtml.getHtml("<h1 style='padding:20px;color:blue'>Bạn đã đặt Tour Thành Công<h1>"));
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setCharacterEncoding("utf-8");
		String name=request.getParameter("fullname");
		String email=request.getParameter("email");
		String phonenumber=request.getParameter("phonenumber");
		String idCTT=request.getParameter("idCTT");
		String number=request.getParameter("number");
		TourDAO da= new TourDAO();
		if(da.InsertDatTour(name, email, number, idCTT, phonenumber))
			response.sendRedirect("Booked");
		
	}

}
